#pragma once

#include <typedef.h>
//
#include <btn.hpp>
#include <rc.hpp>
#include <udp_sender.hpp>
#include <uorb_pub.hpp>
#include <work_queue.hpp>
//
#include <msg_rc_raw_s.hpp>
#include <msg_rc_s.hpp>
//
#include <remoter_cali.hpp>
#include <remoter_cali_finished.hpp>
#include <remoter_cali_normal.hpp>
#include <remoter_cali_pitch_back.hpp>
#include <remoter_cali_pitch_front.hpp>
#include <remoter_cali_prepare.hpp>
#include <remoter_cali_roll_left.hpp>
#include <remoter_cali_roll_right.hpp>
#include <remoter_cali_thro_down.hpp>
#include <remoter_cali_thro_up.hpp>
#include <remoter_cali_yaw_left.hpp>
#include <remoter_cali_yaw_right.hpp>

#define CTL_PWM_MAX	  (9999)
#define CTL_PWM_MIN	  (0)
#define CTL_PWM_SCALE (CTL_PWM_MAX - CTL_PWM_MIN)

class Remoter : public WorkQueue
{
public:
	Remoter();
	virtual ~Remoter();
	static Remoter* Instance();

	void SwitchCaliState(int state);
	void SwitchCaliNext(void);
	int GetCaliState(void);

protected:
	virtual void RunImpl(void* arg);

private:
	Rc m_RcObj;
	Btn m_Btn;
	UorbPub m_PubRc;
	msg_rc_s m_Rc;
	msg_rc_raw_s m_RcRaw;
	UdpSender* m_UdpSender;
	uint64_t m_BtnVal;

	int m_CaliState;
	RemoterCali* m_RcCali[E_RC_CALI_CNT];
	RemoterCali* m_RcCaliCurr;
};
